package com.baizhi.zjs.action;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.baizhi.zjs.entity.BookEntity;
import com.baizhi.zjs.entity.CategoryEntity;
import com.baizhi.zjs.entity.CategoryF;
import com.baizhi.zjs.entity.FUSerEntity;
import com.baizhi.zjs.service.BookService;
import com.baizhi.zjs.service.BookServiceImpl;
import com.baizhi.zjs.service.CategoryServiceImpl;
import com.baizhi.zjs.service.FrontUserServiceImpl;
import com.baizhi.zjs.service.FrontUserServicee;
import com.opensymphony.xwork2.ActionSupport;

public class FCategoryAction extends ActionSupport {
	
	private FUSerEntity fuser;
	//购物时进入登录的标志
		private String deng;
//前台二级页面类别展示
	private List<CategoryF> secondlist;
	private CategoryF  sec;
	
	private CategoryF CFentity1;
	//------------------
private	CategoryEntity cate;
	//------------------book
	private List<BookEntity> list;
	private List<BookEntity> newList;
	private List<BookEntity> newHotList;
	private List<BookEntity> compileList;
	private List<BookEntity> listCategory;
	private BookEntity book11;
	private String id;
	private String id1;
	//前台：分页当前页数
	private Integer pageNum;
	//前台： 每页展示的条数
	private Integer pageSize=3;
	//前台：分页的总页数
	private Integer pageTotal;
	//------------------------
	public String queryAllSecondAction(){
		CategoryServiceImpl impl = new CategoryServiceImpl();
		 BookService impl2 = new BookServiceImpl();
		
		 secondlist = impl.queryAllSecond();
		 
		//--------------------------------前台热销图书---------------- 
		 list = impl2.fShowHotBook();
		//------------------------------前台最新上架
		 newList = impl2.fShowNewBook();
		 
		 //----------------------前台最新热销图书
		  newHotList = impl2.fShNewHotBook();
		  
		  //------------前台编辑推荐,随机展示4本书
		  compileList = impl2.fShowCompile();
		 //-----------------------------
		return "queryAllSecond";
	}
	
	//前台查询一条图书数据详情
	
	public String showOneBookAction(){
		System.out.println("前台查询一条图书数据详情==========");
		System.out.println(id);
		BookService impl = new BookServiceImpl();
		book11 = impl.shoeOneBook(id);
		CategoryServiceImpl impl2 = new CategoryServiceImpl();
		cate = impl2.fshowFirteCateName(id);
		return "showOneBook";
	}
	
		/*public String  showHotBookAction(){
			
			
			return "queryAllSecond";
		}*/
	
	//-----------主页面的左侧查询一及类别和二级类别的详情，点击任意一个类别将会跳转到展示符合该分类的数据
	//前台：分页查询数据信息
	public String showSirstAndTwo(){ 
		//收参id代表一级类别的类别名，id1代表二级类别的类别名
		System.out.println("分页查询=============");
		System.out.println("收参测试");
		System.out.println("一级类别        "+id);
		System.out.println("二级类别    "+id1);
		System.out.println("pageNum ==    "+ pageNum);

		
		CategoryServiceImpl impl = new CategoryServiceImpl();
		BookServiceImpl impl2 = new BookServiceImpl();
		
		
	 CFentity1 = impl.queryOneSecond(id);
	 System.out.println("---------------");
		System.out.println(CFentity1);
			if(pageNum==null){
				pageNum=1;
				listCategory = impl2.queryOneCeateBook(id, id1,pageNum,pageSize);
				//显示总页数
				pageTotal = impl2.queryByPage(id, id1, pageSize);
			}else {
				listCategory = impl2.queryOneCeateBook(id, id1,pageNum,pageSize);
				//显示总页数 一级类别id,二级类别id  每页展示的条数
				pageTotal = impl2.queryByPage(id, id1, pageSize);
			}
			System.out.println(pageTotal);
		System.out.println(listCategory);
		//返回到首页展示
		return "showcateOneAndTwo";
	}
	

	
	//--------------用户登录模块-------------------------------------------------------
	
	
	
	
	
	
	
/*	public String showww(){
		System.out.println("收参测试=====================");
		System.out.println("一级类别        "+id);
		System.out.println("二级类别    "+id1);
		
		
		CategoryServiceImpl impl = new CategoryServiceImpl();
		 CFentity1 = impl.queryOneSecond(id);
		 BookServiceImpl impl2 = new BookServiceImpl();
		 
		 
		 listCategory = impl2.queryOneCeateBook(id, id1pageNum,pageSize);
		System.out.println(cate+"-------=========================");
		return "showcateOneAndTwo";
	}*/
	
	//------------
	
	
	
	
	public List<CategoryF> getSecondlist() {
		return secondlist;
	}
	public void setSecondlist(List<CategoryF> secondlist) {
		this.secondlist = secondlist;
	}


	public List<BookEntity> getList() {
		return list;
	}


	public void setList(List<BookEntity> list) {
		this.list = list;
	}



	public List<BookEntity> getNewList() {
		return newList;
	}



	public void setNewList(List<BookEntity> newList) {
		this.newList = newList;
	}



	public List<BookEntity> getNewHotList() {
		return newHotList;
	}



	public void setNewHotList(List<BookEntity> newHotList) {
		this.newHotList = newHotList;
	}



	public List<BookEntity> getCompileList() {
		return compileList;
	}



	public void setCompileList(List<BookEntity> compileList) {
		this.compileList = compileList;
	}

	

	public BookEntity getBook11() {
		return book11;
	}

	public void setBook11(BookEntity book11) {
		this.book11 = book11;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public CategoryEntity getCate() {
		return cate;
	}

	public void setCate(CategoryEntity cate) {
		this.cate = cate;
	}

	public String getId1() {
		return id1;
	}

	public void setId1(String id1) {
		this.id1 = id1;
	}

	public CategoryF getSec() {
		return sec;
	}

	public void setSec(CategoryF sec) {
		this.sec = sec;
	}

	public CategoryF getCFentity1() {
		return CFentity1;
	}

	public void setCFentity1(CategoryF cFentity1) {
		CFentity1 = cFentity1;
	}

	

	

	public List<BookEntity> getListCategory() {
		return listCategory;
	}

	public void setListCategory(List<BookEntity> listCategory) {
		this.listCategory = listCategory;
	}

	public Integer getPageNum() {
		return pageNum;
	}

	public void setPageNum(Integer pageNum) {
		this.pageNum = pageNum;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getPageTotal() {
		return pageTotal;
	}

	public void setPageTotal(Integer pageTotal) {
		this.pageTotal = pageTotal;
	}

	public FUSerEntity getFuser() {
		return fuser;
	}

	public void setFuser(FUSerEntity fuser) {
		this.fuser = fuser;
	}

	public String getDeng() {
		return deng;
	}

	public void setDeng(String deng) {
		this.deng = deng;
	}
	
	
}
